require 'fileutils'
require File.dirname(__FILE__) + '/.config.rb'

# Spec准备
isExistSpec = Dir.exist?(LOCAL_SPEC_PATH)
if !isExistSpec then
    puts "开始clone #{SPEC_NAME}..."
    log = `cd #{LOCAL_REP_PATH};git clone #{REMOTE_REP_PATH}/#{SPEC_NAME}.git #{SPEC_NAME}`
    puts log
    if $? != 0 then
        raise("#{SPEC_NAME} clone失败~~")
    end
else
    puts "本地#{SPEC_NAME}已经存在，若#{SPEC_NAME}不正确，请删除目录，重新运行脚本"
end

# 准备 iOS 组件仓库
isExistRepository = Dir.exist?(LOCAL_REP_PATH)
if !isExistRepository then
    puts "创建#{LOCAL_REP_PATH}..."
    log = `cd;cd Desktop;mkdir #{LOCAL_REP_PATH}`
    puts log
    if $? != 0 then
        raise("#{LOCAL_REP_PATH} 创建失败~~ 神经！！！")
    end
else
    puts "本地#{LOCAL_REP_PATH}已经存在，若不正确，请删除目录，重新运行脚本"
end

# 组件本地开发
def pod_dev_lib(name, tag)
    puts name + '进入开发模式...'
    require File.dirname(__FILE__) + '/podLibDownload.rb'
    if PodDownload.check_lib_exist(name) != true
      PodDownload.try_check_out(name)
    end
    pod name, :path => LOCAL_REP_PATH + '/' + name + '/'
end

# 准备 Cocoapod repo 
def preparePodSpec
    require File.dirname(__FILE__) + '/podRepoAdd.rb'
end
